package com.briup.security.util;

import lombok.Data;
import lombok.Getter;

@Getter
public class Result<T> {
    /**
     * 业务状态码
     */
    private Integer code;
    /**
     * 状态码信息对应数据
     */
    private String message;

    /**
     * 响应时间
     */
    private Long time;

    /**
     * 响应数据
     */
    private T data;

    private Result(Integer code,String message,T data) {
        this.code = code;
        this.message = message;
        this.time = System.currentTimeMillis();
        this.data = data;
    }

    public static <E> Result<E> success(E data) {
        return new Result<>(200,"成功",data);
    }


    public static  Result success() {
        return success(null);
    }

    public static <E> Result<E> fail(Integer code,String message,E data) {
        return new Result<>(code,message,data);
    }

   public static Result fail(Integer code,String message) {
       return new Result<>(code, message, null);
   }
}

